package jm.nj.demo12mian.demo02;

import java.io.Serializable;

/*
* 序列化和反序列化的类必须实现Serializable 接口,否则不能序列号和反序列化   抛出NotSerializableException异常
* Serializable 接口可以序列化和反序列化,不实现就不能
*
* java.lang.Cloneable:标记型接口,实现Cloneable就可以克隆,不实现就不行
* Cloneable
* 去市场卖--->蓝色合格标签(检疫章)   -->买--->做什么不会管
*
* 静态static 修饰符的属性/方法属于类,不属于类,静态不能序列化
* 不管静态值,还是非静态值,堆内存默认值为0;
*
* transient关键字:被transient修饰的属性不会被序列化
*
* */
public class Person implements Serializable {
    private static final long serialVersionUID = 1234L;

    private String name;
    private int age;

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public Person() {
    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
